package com.qlshouyu.gateway.client.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Application {

    private final static Logger LOGGER = LoggerFactory.getLogger(Application.class);
    private String id;

    /**
     * 应用名称
     */
    private String name;

    /**
     * 应用编号
     */
    private String code;

    /**
     * secret
     */
    private String secret;

    /**
     * 0启用，1禁用
     */
    private Short status;

    /**
     * 创建时间
     */
    private Long createTime;

    /**
     * 授权信息
     */
    private List<AppAuth> auths;

    // api
    private List<ServiceApi> apis;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public List<AppAuth> getAuths() {
        return auths;
    }

    public void setAuths(List<AppAuth> auths) {
        this.auths = auths;
    }

    public List<ServiceApi> getApis() {
        return apis;
    }

    public void setApis(List<ServiceApi> apis) {
        this.apis = apis;
    }

    @Override
    public String toString() {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
            LOGGER.error("Json error", e);
        }
        return null;
    }
}
